<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>我的作品</title>
  </head>
<style>
*{
  margin: 0;
  padding: 0;
}
.back{
  position: absolute;
  top:30px;
  left:15px;
  width: 25px;
  height: 25px;
  background: url("../../image/back.png");
  background-size: 100% 100%;
}
.header{
  background-color: #1296db;
  text-align: center;
  /*margin-top: 15px;*/
  padding-top: 25px;
  padding-bottom: 10px;
  /*height: 45px;*/

}
h3 {
    color: white;
    font-weight: lighter;
}
body{

  background-color: red;
}
.footer{
  height: 57px;
  width: 100%;
  background-color: #81a9c3;
  color: white;
  line-height: 57px;
  text-align: center;
  font-size: 1.2em;
  position: fixed;
  bottom: 0;

}
.main{
  margin-left: 10px;
}
img{
  width: 100px;
  height: 100px;
}

</style>
  <body style="background-color:#fff;">
    <div class="header">
      <a class="back" onclick="back()"></a>
      <h3>提交作品</h3>
    </div>
    <div class="main">
    <div class="upload">
       <span>作品图集上传</span>
       <div class="picture">
         <img class="add" src="../../image/add.png">
       </div>
    </div>
    <div class="introduce">
      <span>作品简介</span>
      <textarea class="word" name="word" rows="8" cols="40"></textarea>
    </div>
    <div class="team">
    <span>团队简介</span>
    <textarea class="tean" name="name" rows="8" cols="40"></textarea>
    </div>
    </div>
  <div class="footer">
    确认提交
  </div>

  </body>
  <script type="text/javascript" src="../../script/jquery-3.2.1.min.js"></script>
  <script type="text/javascript" src="../../script/api.js"></script>
  <script type="text/javascript" src="../../script/main.js"></script>
  <script type="text/javascript">
  // if($(".word").val()!=""){
  //   console.log(111);
  // }

  apiready=function(){
var images=[];
var word=document.getElementsByClassName('word');
var team=document.getElementsByClassName('team');

    back();
    $(".footer").on("touchstart",function(){
      console.log(555);
      console.log(images.length);
      console.log($(".word").val());
      console.log($(".team").val());
      if (images.length>0&&$(".word").val()!=""&&$(".tean").val()!="") {
        api.alert({
            title: '提示',
            msg: '假的提交成功',
        }, function(ret, err){
            if( ret ){
                 alert( JSON.stringify( ret ) );
            }else{
                 alert( JSON.stringify( err ) );
            }
        });

// api.alert("假的提交成功");
      }else {
        api.alert({
            title: '提示',
            msg: '都是假的！',
        }, function(ret, err){
            if( ret ){
                 alert( JSON.stringify( ret ) );
            }else{
                 alert( JSON.stringify( err ) );
            }
        });

        // api.alert("都是假的");
      }
    })

  $(".add").on("touchstart",function(){
    api.confirm({
      title:'选取图片',
      msg:'选择导入方式',
      buttons:['拍照','相册','取消']
    },function(ret,err){
      if (ret.buttonIndex==3) {
        console.log(11);
        // return;
      }if (ret.buttonIndex==2) {
        console.log(123);
      }
    if (ret.buttonIndex==1) {
      console.log(321);
      api.getPicture({
          sourceType: 'camera',
          encodingType: 'png',
          mediaValue: 'pic'
      }, function(ret, err) {
          if (ret.data.length) {
            var len = images.length;
            images[len] = ret.data;
            var imgHTML="<img class='browser' src='"+images[len]+"'onclick = 'browserImage("+len+")'>";
            $(".add").before(imgHTML);
            if(images.length>8){
              $('.add').hide();
            }
          }
      });
    }
    }
  )
  })

  }


  </script>
</html>
